package edu.zqu.course.project.controller;


import edu.zqu.common.result.ZQUResult;
import edu.zqu.course.project.domain.pojo.CourseSyllabusContent;
import edu.zqu.course.project.service.CourseSyllabusContentService;
import edu.zqu.course.response.ChapterShow;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 * 课程大纲明细，即：知识点 前端控制器
 * </p>
 *
 * @author 郭泽鹏
 * @since 2020-06-24
 */
@RestController
@RequestMapping("/course-syllabus-content")
@Api(tags = "课程大纲明细，即：知识点 前端控制器")
public class CourseSyllabusContentController {
    @Resource
    CourseSyllabusContentService courseSyllabusContentService;

    /**
     *
     * @return
     * 查询操作
     */
    @GetMapping("/list")
    @ApiOperation(value = "查询所有")
    public ZQUResult getCourseSyllabusContentList(){
        return ZQUResult.success("查询成功", courseSyllabusContentService.getCourseSyllabusContentList());
    }

    @GetMapping("/chapter_show/{id}")
    @ApiOperation(value = "章展示：通过章id查询")
    public ZQUResult getChapterShowById(@PathVariable(value = "id") String id,
                                        Integer page, Integer size){
        List<ChapterShow> chapterShows = courseSyllabusContentService.getChapterShowById(id, page, size);
        return ZQUResult.success("查询成功", chapterShows);
    }

    /**
     * 删除操作
     */
    @DeleteMapping("/list")
    @ApiOperation(value = "删除所有")
    public ZQUResult deleteCourseSyllabusContentList(){
        Integer result = courseSyllabusContentService.deleteCSCs();
        return ZQUResult.success("删除成功", result);
    }

    @DeleteMapping("/{id}")
    @ApiOperation(value = "通过节id删除")
    public ZQUResult deleteByCSCId(@PathVariable("id") Long id){
        Integer result = courseSyllabusContentService.deleteByCSCId(id);
        return ZQUResult.success("删除成功", result);
    }

    @DeleteMapping("/csc_show/{cs_id}/{csd_id}")
    @ApiOperation(value = "节展示：通过课程大纲id和课程大纲内容(章)id查询")
    public ZQUResult deleteCourseSyllabusContentByCsdId(@PathVariable("cs_id") String csId,
                                                     @PathVariable("csd_id") String csdId){
        return ZQUResult.success("删除成功", null);
    }

    /**
     * 添加操作
     */
    @PostMapping("")
    @ApiOperation(value = "添加课程大纲明细")
    public ZQUResult inserttCourseSyllabusContent(@RequestBody CourseSyllabusContent courseSyllabusContent){
        Integer result = courseSyllabusContentService.insertCourseSyllabusContent(courseSyllabusContent);
        return ZQUResult.success("添加成功", result);
    }
}

